//
//  AXMyAddDiseaseManageVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/12.
//  Copyright © 2018 tzhg. All rights reserved.
//
/** 新增病害 */
#import "AXMyAddDiseaseManageVC.h"
#import "UIView+SDAutoLayout.h"
#import "AXMyOtherManageModel.h"
#import "UITableView+SDAutoTableViewCellHeight.h"
#import "UIViewController+HBD.h"
#import "AXMyOtherManageVC.h"
#import "AXMyMorbidityNameCell.h"
#import "AXMyMorbidityCell.h"
#import "AXFzyjCell.h"
#import "AXMyAddMedicamentCell.h"
#import "AXMYMethodCell.h"
#import "AXMyWeatherCell.h"


@interface AXMyAddDiseaseManageVC ()<UITableViewDelegate,UITableViewDataSource>

//@property (nonatomic ,strong) NSMutableArray<AXMyOtherManageModel*> *modelsArray;
@property (nonatomic , strong) UITableView *tableView;
@property (nonatomic , strong) UIView *footerView;

@end

@implementation AXMyAddDiseaseManageVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatView];
    [self setlayout];
    [self setupNavigationItems];
    self.view.backgroundColor = [UIColor whiteColor];
    self.hbd_barTintColor = [UIColor whiteColor];
    self.hbd_barShadowHidden = YES;
    
    /** tableview 的表尾按钮 */
    self.tableView.tableFooterView = _footerView;
    _footerView.backgroundColor = [UIColor whiteColor];
    self.tableView.tableFooterView = _footerView;
    
    
    
}

- (void)creatView {
    
    _footerView = [[UIView alloc]init];
    
    UIButton *saveBtn = [[UIButton alloc]init];
    saveBtn.backgroundColor = COLOR_GREEN;
    saveBtn.cornerRadius = 5;
    [saveBtn setTitle:@"保存" forState:UIControlStateNormal];
    [saveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [saveBtn addTarget:self action:@selector(add:) forControlEvents:UIControlEventTouchUpInside];
    [self.footerView addSubview:saveBtn];
    
    
    saveBtn.sd_layout
    .leftSpaceToView(self.footerView, 50)
    .topSpaceToView(_footerView, 56)
    .widthIs(SCREEN_WIDTH-100)
    .heightIs(44);
    
    self.tableView = [[UITableView alloc]init];
    self.tableView.backgroundColor = [UIColor whiteColor];
    /** 去掉cell线 */
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    _footerView.frame = CGRectMake(0, 56, SCREEN_WIDTH, 100);
    self.tableView.tableFooterView = self.footerView;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[AXMyMorbidityNameCell class] forCellReuseIdentifier:[AXMyMorbidityNameCell reuseID]];
    [self.tableView registerClass:[AXMyMorbidityCell class] forCellReuseIdentifier:[AXMyMorbidityCell reuseID]];
    [self.tableView registerClass:[AXFzyjCell class] forCellReuseIdentifier:[AXFzyjCell reuseID]];
    [self.tableView registerClass:[AXMyAddMedicamentCell class] forCellReuseIdentifier:[AXMyAddMedicamentCell reuseID]];
    [self.tableView registerClass:[AXMYMethodCell class] forCellReuseIdentifier:[AXMYMethodCell reuseID]];
    [self.tableView registerClass:[AXMyWeatherCell class] forCellReuseIdentifier:[AXMyWeatherCell reuseID]];
    [self.view addSubview:self.tableView];
}



- (void)setlayout {
    
    self.tableView.sd_layout
    .leftSpaceToView(self.view, 0)
    .topSpaceToView(self.view, Hn)
    .widthIs(SCREEN_WIDTH)
    .heightIs(TableViewHeight);
}


- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    /** 搜索 */
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
    titleLabel.text = @"病害管理";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = FONT_FOURTEEN;
    titleLabel.textColor = [UIColor colorWithHex:0x29b566];
    self.navigationItem.titleView = titleLabel;
    
   
    
}

#pragma mark - Action

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)add:(UIButton *)btn {
    
    AXMyOtherManageVC *vc = [[AXMyOtherManageVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
    
}




#pragma mark - tableViewDelegate & tableViewDatasorce


//几个分区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 8;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}

/** cell的高度 */

/** cell 自适应第二步 */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if (indexPath.section == 3||indexPath.section == 4) {
        
        return 100;
    }
    
    
    return 44;
    
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    switch (indexPath.section) {
        case 0:{
            
          AXMyMorbidityNameCell *nameCell = [tableView dequeueReusableCellWithIdentifier:[  AXMyMorbidityNameCell reuseID] forIndexPath:indexPath];
            nameCell.accessoryType =  UITableViewCellAccessoryDisclosureIndicator;
            nameCell.titleLabel.text = @"病害名称";
            [nameCell.selectBtn setTitle:@"请选择" forState:UIControlStateNormal];
            
            return nameCell;
            
        }
            
            break;
        case 1:{
            
            AXMyMorbidityCell *morbidityCell = [tableView dequeueReusableCellWithIdentifier:[AXMyMorbidityCell reuseID] forIndexPath:indexPath];

            morbidityCell.titleLabel.text = @"发病率：  %";
            morbidityCell.textField.placeholder = @"病情指数%";
            
            return morbidityCell;
            
        }
            
            break;
        case 2:{
            
            AXFzyjCell *yjCell = [tableView dequeueReusableCellWithIdentifier:[AXFzyjCell reuseID] forIndexPath:indexPath];
            
            yjCell.titleLabel.text = @"防治药剂";
           
            
            return yjCell;
            
        }
            
            break;
        case 3:{
            
            AXMyAddMedicamentCell *fzyjCell = [tableView dequeueReusableCellWithIdentifier:[AXMyAddMedicamentCell reuseID] forIndexPath:indexPath];
            
            fzyjCell.yjmcLabel.text = @"药剂名称";
            fzyjCell.sylLabel.text = @"施用量";
            
            
            
            return fzyjCell;
            
        }
            
            break;
        case 4:{
            
            
            AXMYMethodCell *methodCell = [tableView dequeueReusableCellWithIdentifier:[AXMYMethodCell reuseID] forIndexPath:indexPath];
            
            methodCell.titleLabel.text = @"施用方法";
            
            
            
            return methodCell;
           
            
        }
            
            break;
            
        case 5:{
            
            
            AXMyMorbidityCell *morbidityCell = [tableView dequeueReusableCellWithIdentifier:[AXMyMorbidityCell reuseID] forIndexPath:indexPath];
            
            morbidityCell.titleLabel.text = @"防治面积";
            morbidityCell.textField.placeholder = @"点击填写亩";
            
            return morbidityCell;
            
        }
            
            break;
            
        case 6:{
            
            AXMyMorbidityNameCell *nameCell = [tableView dequeueReusableCellWithIdentifier:[  AXMyMorbidityNameCell reuseID] forIndexPath:indexPath];
            nameCell.accessoryType =  UITableViewCellAccessoryDisclosureIndicator;
            nameCell.titleLabel.text = @"施药时间";
           
            return nameCell;
        
            
        }
            
            break;

            
        default:
            break;
    }
    
   
    AXMyWeatherCell *weatherCell = [tableView dequeueReusableCellWithIdentifier:[AXMyWeatherCell reuseID] forIndexPath:indexPath];
    
    weatherCell.weatherLabel.text = @"天气";
    weatherCell.temperatureLabel.text = @"气温";
    
    //管理按钮的事件
    
    
    
    return weatherCell;
    
    
}




@end






